package dao;

import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * A data access object (DAO) providing persistence and search support for
 * Yunjia entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see dao.Yunjia
 * @author MyEclipse Persistence Tools
 */

public class YunjiaDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(YunjiaDAO.class);
	// property constants
	public static final String YUNJIACODE = "yunjiacode";
	public static final String STARTADDR6 = "startaddr6";
	public static final String ENDADDR6 = "endaddr6";
	public static final String YUNSHUMODE = "yunshumode";
	public static final String TIMECOST = "timecost";
	public static final String YUNJIASTATUS = "yunjiastatus";
	public static final String TEJIA = "tejia";
	public static final String YUNJIAINFO = "yunjiainfo";
	public static final String PRICE1 = "price1";
	public static final String BASEPRICE1 = "baseprice1";
	public static final String BIZHONG1 = "bizhong1";
	public static final String YUNSHUUNIT1 = "yunshuunit1";
	public static final String PRICE2 = "price2";
	public static final String BASEPRICE2 = "baseprice2";
	public static final String BIZHONG2 = "bizhong2";
	public static final String YUNSHUUNIT2 = "yunshuunit2";
	public static final String PRICE3 = "price3";
	public static final String BASEPRICE3 = "baseprice3";
	public static final String BIZHONG3 = "bizhong3";
	public static final String YUNSHUUNIT3 = "yunshuunit3";
	public static final String PRICE4 = "price4";
	public static final String BASEPRICE4 = "baseprice4";
	public static final String BIZHONG4 = "bizhong4";
	public static final String YUNSHUUNIT4 = "yunshuunit4";
	public static final String PRICE5 = "price5";
	public static final String BASEPRICE5 = "baseprice5";
	public static final String BIZHONG5 = "bizhong5";
	public static final String YUNSHUUNIT5 = "yunshuunit5";

	protected void initDao() {
		// do nothing
	}

	public void save(Yunjia transientInstance) {
		log.debug("saving Yunjia instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Yunjia persistentInstance) {
		log.debug("deleting Yunjia instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Yunjia findById(java.lang.Integer id) {
		log.debug("getting Yunjia instance with id: " + id);
		try {
			Yunjia instance = (Yunjia) getHibernateTemplate().get("dao.Yunjia",
					id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Yunjia instance) {
		log.debug("finding Yunjia instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Yunjia instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Yunjia as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByYunjiacode(Object yunjiacode) {
		return findByProperty(YUNJIACODE, yunjiacode);
	}

	public List findByStartaddr6(Object startaddr6) {
		return findByProperty(STARTADDR6, startaddr6);
	}

	public List findByEndaddr6(Object endaddr6) {
		return findByProperty(ENDADDR6, endaddr6);
	}

	public List findByYunshumode(Object yunshumode) {
		return findByProperty(YUNSHUMODE, yunshumode);
	}

	public List findByTimecost(Object timecost) {
		return findByProperty(TIMECOST, timecost);
	}

	public List findByYunjiastatus(Object yunjiastatus) {
		return findByProperty(YUNJIASTATUS, yunjiastatus);
	}

	public List findByTejia(Object tejia) {
		return findByProperty(TEJIA, tejia);
	}

	public List findByYunjiainfo(Object yunjiainfo) {
		return findByProperty(YUNJIAINFO, yunjiainfo);
	}

	public List findByPrice1(Object price1) {
		return findByProperty(PRICE1, price1);
	}

	public List findByBaseprice1(Object baseprice1) {
		return findByProperty(BASEPRICE1, baseprice1);
	}

	public List findByBizhong1(Object bizhong1) {
		return findByProperty(BIZHONG1, bizhong1);
	}

	public List findByYunshuunit1(Object yunshuunit1) {
		return findByProperty(YUNSHUUNIT1, yunshuunit1);
	}

	public List findByPrice2(Object price2) {
		return findByProperty(PRICE2, price2);
	}

	public List findByBaseprice2(Object baseprice2) {
		return findByProperty(BASEPRICE2, baseprice2);
	}

	public List findByBizhong2(Object bizhong2) {
		return findByProperty(BIZHONG2, bizhong2);
	}

	public List findByYunshuunit2(Object yunshuunit2) {
		return findByProperty(YUNSHUUNIT2, yunshuunit2);
	}

	public List findByPrice3(Object price3) {
		return findByProperty(PRICE3, price3);
	}

	public List findByBaseprice3(Object baseprice3) {
		return findByProperty(BASEPRICE3, baseprice3);
	}

	public List findByBizhong3(Object bizhong3) {
		return findByProperty(BIZHONG3, bizhong3);
	}

	public List findByYunshuunit3(Object yunshuunit3) {
		return findByProperty(YUNSHUUNIT3, yunshuunit3);
	}

	public List findByPrice4(Object price4) {
		return findByProperty(PRICE4, price4);
	}

	public List findByBaseprice4(Object baseprice4) {
		return findByProperty(BASEPRICE4, baseprice4);
	}

	public List findByBizhong4(Object bizhong4) {
		return findByProperty(BIZHONG4, bizhong4);
	}

	public List findByYunshuunit4(Object yunshuunit4) {
		return findByProperty(YUNSHUUNIT4, yunshuunit4);
	}

	public List findByPrice5(Object price5) {
		return findByProperty(PRICE5, price5);
	}

	public List findByBaseprice5(Object baseprice5) {
		return findByProperty(BASEPRICE5, baseprice5);
	}

	public List findByBizhong5(Object bizhong5) {
		return findByProperty(BIZHONG5, bizhong5);
	}

	public List findByYunshuunit5(Object yunshuunit5) {
		return findByProperty(YUNSHUUNIT5, yunshuunit5);
	}

	public List findAll() {
		log.debug("finding all Yunjia instances");
		try {
			String queryString = "from Yunjia";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Yunjia merge(Yunjia detachedInstance) {
		log.debug("merging Yunjia instance");
		try {
			Yunjia result = (Yunjia) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Yunjia instance) {
		log.debug("attaching dirty Yunjia instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Yunjia instance) {
		log.debug("attaching clean Yunjia instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static YunjiaDAO getFromApplicationContext(ApplicationContext ctx) {
		return (YunjiaDAO) ctx.getBean("YunjiaDAO");
	}
}